/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
using System;
using VMukti.DataAccess;
using VMuktiAPI;


namespace VMukti.Business
{
    public class UserCollection : ClsBaseCollection<ClsUser>
    {
        public static UserCollection GetAll()
        {
            try
            {
                UserCollection obj = new UserCollection();
                if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp)
                {
                    try
                    {
                        obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select UserInfo.*,Payroll.* from UserInfo left outer join Payroll on UserInfo.Id=Payroll.UserId where UserInfo.IsDeleted=0;").dsInfo);
                    }
                    catch (System.ServiceModel.EndpointNotFoundException e)
                    {
                        e.Data.Add("My Key", "GetAll()--:--ClsUserCollection.cs--:--" + e.Message + " :--:--");
                        ClsException.LogError(e);
                        ClsException.WriteToErrorLogFile(e);
                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select UserInfo.*,Payroll.* from UserInfo left outer join Payroll on UserInfo.Id=Payroll.UserId where UserInfo.IsDeleted=0;").dsInfo);
                    }
                    catch (System.ServiceModel.CommunicationException e)
                    {
                        e.Data.Add("My Key", "GetAll()--:--ClsUserCollection.cs--:--" + e.Message + " :--:--");
                        ClsException.LogError(e);
                        ClsException.WriteToErrorLogFile(e);
                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        obj.MapObjects(VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("Select UserInfo.*,Payroll.* from UserInfo left outer join Payroll on UserInfo.Id=Payroll.UserId where UserInfo.IsDeleted=0;").dsInfo);
                    }  
                    
                }
                else
                {                    
                    obj.MapObjects(new ClsUserDataService().User_GetAll());                    
                }
                return obj;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "VMukti--:--Vmukti.Business--:--User--:--clsUserCollection.cs--:--GetAll()--");
                return null;
            }
        }

    }
}
